// 云对象教程: https://uniapp.dcloud.net.cn/uniCloud/cloud-obj
// jsdoc语法提示教程：https://ask.dcloud.net.cn/docs/#//ask.dcloud.net.cn/article/129
const db = uniCloud.database(); //代码块为cdb
module.exports = {
	_before: function () { // 通用预处理器

	},
	
	async list(page){
		page = page ?  1 : page
		return await db.collection('tb_jielong').skip((page-1)*5) .limit (5).get()
	},
	async add(param1) {
		let res = await db.collection('tb_jielong').add(param1)
		return {
			code: 200,
			success:true,
			message: '添加成功'
		}
	},
	async edit(param1) {
		let res = await db.collection('tb_jielong').doc(param1._id).update(param1)
		return {
			code: 200,
			success:true,
			message: '编辑成功'
		}
	},
	async delete(id) {
		let res = await db.collection('tb_jielong').doc(id).remove()
		return {
			code: 200,
			success:true,
			message: '删除成功'
		}
	},
	async queryById(id) {
		let res = await db.collection('tb_jielong').doc(id).get()
		return res.result.data
	},
	
	
}
